import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';


import '../../AppConfig/Config.dart';
import '../../AppConfig/RouteAct.dart';
import 'AddbankCard.dart';
import 'Withdrawal.dart';

class WithdrawalBalance extends StatefulWidget {
  const WithdrawalBalance({super.key});

  @override
  State<WithdrawalBalance> createState() => _WithdrawalBalanceState();
}

class _WithdrawalBalanceState extends State<WithdrawalBalance> {
  int cardIndex=0;
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        title: Text("提现",style: TextStyle(fontWeight: FontWeight.w300,fontSize: 16.sp),),
        centerTitle: true,
        backgroundColor: Colors.white,
        leading: IconButton(
          icon: Icon(Icons.arrow_back_ios, color: Colors.black),
          onPressed: () => Navigator.of(context).pop(),
        ),
        actions: [
          TextButton(onPressed: (){
            showDialog(
              barrierDismissible: false,
              context: context,
              builder: (BuildContext context) {
                return BrnDialog(
                  titleText: "提现限额说明",
                    contentWidget:Container(
                      padding: EdgeInsets.only(left: 8.w,right: 8.w),

                      child: Table(
                        border: TableBorder.all(),
                        children: [
                          TableRow(
                            children: [
                              TableCell(child: Center(child: Text('认证方式'))),
                              TableCell(child: Center(child: Text('单日单笔限额'))),
                              TableCell(child: Center(child: Text('单月限额'))),
                            ],
                          ),
                          TableRow(
                            children: [
                              TableCell(child: Center(child: Text('身份证实名'))),
                              TableCell(child: Center(child: Text('5000'))),
                              TableCell(child: Center(child: Text('10000'))),
                            ],
                          ),
                          TableRow(
                            children: [
                              TableCell(child: Center(child: Text('身份证实名\n+银行卡绑卡'))),
                              TableCell(child: Center(child: Text('10000'))),
                              TableCell(child: Center(child: Text('20000'))),
                            ],
                          ),
                          TableRow(
                            children: [
                              TableCell(child: Center(child: Text('身份证实名\n+银行卡绑卡\n+人脸认证'))),
                              TableCell(child: Center(child: Text('50000'))),
                              TableCell(child: Center(child: Text('100000'))),
                            ],
                          ),
                        ],
                      ),
                    ),
                  actionsWidget: [
                    TextButton(
                      onPressed: () {
                        Navigator.pop(context);
                      },
                      child: Text("知道了",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                    ),
                  ],
                );
              },
            );
          }, child: Text("限额说明",style: TextStyle(color:Colors.black,fontSize: 13.sp,))),
        ],
      ),
      body: ListView(
        children: [
          GestureDetector(
            child: Container(
              padding: EdgeInsets.only(left: 15.w,right: 15.w,top: 10.h),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text("到账银行卡",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600),),
                  SizedBox(height: 10.h,),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          Image.asset("lib/Images/PersonCenter/中国银行icon.png",width: 20.w,height: 20.h,),
                          SizedBox(width: 8.w,),
                          Text("中国银行储蓄卡(1234)",style: TextStyle(color: MyColors.textColor,fontSize: 16.sp),),
                        ],
                      ),
                      Icon(Icons.arrow_forward_ios,color: MyColors.textColor,size: 16,),
                    ],
                  ),
                SizedBox(height: 4.h,),
                Text("提现成功后，预计3-7个工作日到账",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                ],
              ),
            ),
            onTap: (){
              showModalBottomSheet(
                  context: context,
                  builder: (BuildContext context) {
                    return Container(
                      padding: EdgeInsets.only(top: 10.h,left: 10.w,right: 10.w),
                      height: 300.h,
                     width: screenSize.width,
                      decoration: BoxDecoration(
                          color:Colors.white,
                          borderRadius: BorderRadius.all(Radius.circular(10))),
                      child: Column(
                        children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            SizedBox(width: 15.w,),
                            Text("选择银行卡",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                            IconButton(onPressed: (){Navigator.pop(context);}, icon: Icon(Icons.close,color: MyColors.textColor,size: 30,)),
                          ],
                        ),
                          Divider(height: 16.h,color: MyColors.backgreyColor,),
                          Container(
                            height: 135.h,
                            child: ListView.builder(
                                itemCount: 3,
                                itemBuilder: (context, index) {
                                  return GestureDetector(
                                    child:  Column(
                                      children: [
                                        Row(
                                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                          children: [
                                            Row(
                                              children: [
                                                Image.asset("lib/Images/PersonCenter/中国银行icon.png",width: 30.w,height: 30.h,),
                                                SizedBox(width: 8.w,),
                                                Text("中国银行储蓄卡(1234)",style: TextStyle(color: MyColors.textColor,fontSize: 16.sp),),
                                              ],
                                            ),
                                         if( cardIndex==index)  Icon(Icons.check_circle,color: MyColors.themeColor,),
                                          ],
                                        ),
                                        Divider(height: 16.h,color: MyColors.backgreyColor,),
                                      ],
                                    ),
                                    onTap: (){
                                      setState(() {
                                        cardIndex=index;
                                        Navigator.pop(context);
                                      });
                                    },
                                  );
                                }
                            ),
                          ),
                          GestureDetector(
                            child: Container(
                              child:  Row(
                                children: [
                                  Icon(Icons.control_point,color: MyColors.textColor,),
                                  Text("添加银行卡",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                                ],
                              ),
                            ),
                            onTap: (){
                              Navigator.pop(context);
                              Navigator.push( context, FadeRoute(page:AddBankCard()));
                            },
                          )
    
                        ],
                      ),
                    );
                  }
              );
            },
          ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h,bottom: 10.h),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("可提现余额",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                    Text("100.00元",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                  ],
                ),
                Divider(height: 16.h,color: MyColors.backgreyColor,),
                GestureDetector(
                  child:   Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text("待结算金额:100.00元",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                      Row(
                        children: [
                          Text("去结算",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                          Icon(Icons.arrow_forward_ios,size: 14,color: MyColors.authTipColor,)
                        ],
                      )
                    ],
                  ),
                  onTap: (){
                    Navigator.push( context, FadeRoute(page:Withdrawal(
                    )));
                  },
                ),

                Divider(height: 16.h,color: MyColors.backgreyColor,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("提现金额",style: TextStyle(color: MyColors.textColor,fontSize: 13.sp),),
                  ],
                ),


                Container(
                  margin: EdgeInsets.only(top: 8.h),
                  padding: EdgeInsets.only(left: 15.w,right: 15.w),
                  height: 40.h,
                  decoration: BoxDecoration(
                      color: MyColors.backgreyColor,
                      borderRadius: BorderRadius.all(Radius.circular(10))),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text("¥",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                      Container(
                        width: screenSize.width-120.w,
                        child: TextField(

                          decoration: InputDecoration(
                            border: InputBorder.none,
                            hintText:'请输入提现金额',
                            hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),

                            filled: true,
                            fillColor: MyColors.backgreyColor,
                            // border: InputBorder.none,
                            alignLabelWithHint: true,
                            // contentPadding: EdgeInsets.symmetric(vertical: 6.0.h, horizontal: 0.0.w),
                          ),
                          textAlign: TextAlign.left,
                          style: TextStyle(color: Colors.black),
                          onChanged: (value) {
                            setState(() {

                              print(value);
                            });
                          },
                        ),
                      ),
                    ],
                  ),
                ),
                SizedBox(height: 20.h,),
                BrnSmallMainButton(
                  title: '立即提现',
                  bgColor: MyColors.themeColor,
                  textColor: Colors.white,
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w600,
                  width: screenSize.width-40.w,
                  radius: 30,
                  onTap: () {

                  },
                )
              ],
            ),
          ),
          
        ],
      ),
    );
  }
}
